-
Notifications
You must be signed in to change notification settings - Fork 782
Fork safe ConcurrentMultiSpanProcessor #4862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fork safe ConcurrentMultiSpanProcessor #4862
Conversation
|
|
3abcc2e to
f98d672
Compare
8e7c298 to
808fe91
Compare
808fe91 to
071b2de
Compare
071b2de to
ac36ce2
Compare
|
@DylanRussell thanks a lot for the review.
There's another test which failed but it doesn't look like it's related to my change, see https://github.com/open-telemetry/opentelemetry-python/actions/runs/20662185256/job/59826483790#step:6:39 Can you relaunch the CI please? |
|
There's still a CI step failing but I have no idea how I can fix this. It looks like a bug/flakiness in the CI workflow |
|
Yeah don't worry about that it's a very common flake that randomly occurs on tests, some sort of race condition I think |
Description
ConcurrentMultiSpanProcessoris not "fork safe". This MR tries to solve this problem.Forking a threaded process is not a good idea in the first place, citing the Python doc, see https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
Also, the OTel Python SDK suggest to only initialize the SDK post fork, see https://opentelemetry-python.readthedocs.io/en/latest/examples/fork-process-model/README.html
Nevertheless, on an existing code base, it's not always easy to avoid all forks. So it looks like a good idea to try and make the SDK as fork safe as possible.
Note:
BatchProcessoris already relying onregister_at_forkused here, seeopentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_shared_internal/__init__.py
Line 125 in 102fec2
Fixes #2349
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
See unit test and discussions below.
An equivalent patch is currently running in our stack.
Does This PR Require a Contrib Repo Change?
?
Checklist: